package com.lecture.java8.excel.dyr.a;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.Locale;

public class Test {

    public static void main(String[] args) {
        String excelDate = "1三月-25";

        // 1. 定义 DateTimeFormatter（注意：MMMM 代表完整月份）
        DateTimeFormatter inputFormatter = DateTimeFormatter.ofPattern("MMMM-yy", Locale.CHINESE);
        DateTimeFormatter outputFormatter = DateTimeFormatter.ofPattern("yyyy-MM");

        try {
            // 2. 解析字符串
            DateTimeFormatter fixedInputFormatter = DateTimeFormatter.ofPattern("dMMMM-yy", Locale.CHINESE);
            LocalDate date = LocalDate.parse(excelDate, fixedInputFormatter);

            System.out.println(date); // 输出：2025-03
        } catch (DateTimeParseException e) {
            System.out.println("解析失败：" + e.getMessage());
        }
    }
}
